﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Infragistics.Controls.Schedules;
using Ivvy_Silverlight.i7SR;

namespace Ivvy_Silverlight.Ivvy
{
    public class ExtendedAppoIntMent : Appointment
    {
        public static int CurId = 0;

        public static string GetNextAppointmentID()
        {
            return System.Guid.NewGuid().ToString();
            //return "t" + (++CurId).ToString();
        }
        public i_vw_Appointment_Summary Appointment_Summary = new i_vw_Appointment_Summary();        

        public ExtendedAppoIntMent() 
        {
            SetDefaultValues();
        }//public ExtendedAppoIntMent() 

        public ExtendedAppoIntMent(ExtendedAppoIntMent SrcExtendedAppoIntMent)
        {
            SetDefaultValues();
            SetFromExtendedAppoIntMent(SrcExtendedAppoIntMent);
        }//public ExtendedAppoIntMent() 

        public void SetDefaultValues()
        {
            fillColorEx = new SolidColorBrush(Color.FromArgb(255, 255, 255, 120)); 
        }

        private Brush fillColorEx;

        public Brush FillColorEx
        {
            get
            {
                return fillColorEx;
            }
            set
            {
                fillColorEx = value;
            }
        }

        public void SetFromAppointment(Appointment SrcAppointment)
        {   
            this.Description = SrcAppointment.Description;            
            this.End = SrcAppointment.End;
            this.EndTimeZoneId = SrcAppointment.EndTimeZoneId;
            this.Error = SrcAppointment.Error;
            this.Id = SrcAppointment.Id;
            this.IsLocked = SrcAppointment.IsLocked;            
            this.IsOccurrenceDeleted = SrcAppointment.IsOccurrenceDeleted;            
            this.IsTimeZoneNeutral = SrcAppointment.IsTimeZoneNeutral;
            this.IsVariance = SrcAppointment.IsVariance;
            this.IsVisible = SrcAppointment.IsVisible;            
            this.LastModifiedTime = SrcAppointment.LastModifiedTime;
            this.MaxOccurrenceDateTime = SrcAppointment.MaxOccurrenceDateTime;            
            this.OriginalOccurrenceEnd = SrcAppointment.OriginalOccurrenceEnd;
            this.OriginalOccurrenceStart = SrcAppointment.OriginalOccurrenceStart;
            this.OwningCalendar = SrcAppointment.OwningCalendar;
            this.OwningCalendarId = SrcAppointment.OwningCalendarId;
            this.OwningResource = SrcAppointment.OwningResource;
            this.OwningResourceId = SrcAppointment.OwningResourceId;
            this.Recurrence = SrcAppointment.Recurrence;
            this.RecurrenceVersion = SrcAppointment.RecurrenceVersion;
            this.Reminder = SrcAppointment.Reminder;
            this.ReminderEnabled = SrcAppointment.ReminderEnabled;
            this.ReminderInterval = SrcAppointment.ReminderInterval;
            this.RootActivity = SrcAppointment.RootActivity;
            this.RootActivityId = SrcAppointment.RootActivityId;
            this.Start = SrcAppointment.Start;
            this.StartTimeZoneId = SrcAppointment.StartTimeZoneId;
            this.Subject = SrcAppointment.Subject;            
        }//public void SetFromAppointment(Appointment SrcAppointment)

        public void SetFromExtendedAppoIntMent(ExtendedAppoIntMent SrcExtendedAppoIntMent)
        {
            this.Appointment_Summary = SrcExtendedAppoIntMent.Appointment_Summary;
            this.OwningResourceId = SrcExtendedAppoIntMent.OwningResourceId;
            this.OwningCalendarId = SrcExtendedAppoIntMent.OwningCalendarId;
            this.FillColorEx = SrcExtendedAppoIntMent.FillColorEx;
            this.Subject = SrcExtendedAppoIntMent.Subject;
            this.IsTimeZoneNeutral = SrcExtendedAppoIntMent.IsTimeZoneNeutral;
            this.Location = SrcExtendedAppoIntMent.Location;
            this.Description = SrcExtendedAppoIntMent.Description;
            this.Start = SrcExtendedAppoIntMent.Start;
            this.End = SrcExtendedAppoIntMent.End;
        }

        public void UpdateFillColorEx()
        {
            SetFillColorExFrom_StatusID(Appointment_Summary.Status_ID);
        }

        public void SetFillColorExFrom_StatusID(int? StatusID)
        {
            Color NewColor = Color.FromArgb(255,255,255,120);            
            if(StatusID == 169)
                NewColor = Colors.Yellow;
            else if(StatusID == 121)
                NewColor = Colors.Purple;
            else if(StatusID == 170)
                NewColor = Colors.LightGray;
            else if(StatusID == 119)
                NewColor = Colors.Green;
            else if(StatusID == 122)
                NewColor = Colors.Magenta;
            else if(StatusID == 123)
                NewColor = Colors.Orange;
            else if(StatusID == 120)
                NewColor = Colors.Cyan;
            fillColorEx = new SolidColorBrush(NewColor); 
        }//public void SetFillColorExFrom_StatusID(int? StatusID)
    }//public class ExtendedAppoIntMent : Appointment
}//namespace Ivvy_Silverlight.Ivvy
